package util;

public class DistanceUtil {

    /**
     * EUC_2D 欧式距离
     */
    public static int calculateEuc2D(int x1, int y1, int x2, int y2) {
        double distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
        return (int) (distance + 0.5);
    }

    /**
     * ATT 伪欧式距离 pseudo euclidean
     */
    public static int calculateATT(int x1, int y1, int x2, int y2) {
        double distance = Math.sqrt(((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) / 10d);
        return (int) Math.ceil(distance);
    }

    public static double calculateEuc2D(double x1, double y1, double x2, double y2) {
        return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
    }
}
